<template>
  <div class="home">
    <div class="header">
      <div class="header_nav">
        <div class="nav_l">
          <h3>源聚通</h3>
          <p>YuanJu Venture Capital</p>
        </div>
        <div class="nav_r">
          <img @click="qiandao" src="@/assets/img/home/qiandao.png" />
        </div>
      </div>
    </div>

    <div class="banner">
      <div class="swiper-container">
        <div class="swiper-wrapper">
          <div
            class="swiper-slide"
            v-for="(item, index) in images"
            :key="index"
          >
            <img class="swiper-img" :src="item.thumb" />
          </div>
        </div>
      </div>
      <div class="swiper-pagination"></div>
    </div>
    <div class="content">
      <!--  @click="orderlist" -->
      <div class="tip">
        <img
          class="icon"
          :src="require('@/assets/img/home/youliaocaifu.png')"
        />
        <!-- <p>{{ data.notice }}</p> -->
        <van-notice-bar scrollable :text="data.notice" background="#f7f7f9" />
      </div>
      <div class="model">
        <div class="model_l" @click="capitaldetails">
          <p>我要充值</p>
        </div>
        <div class="model_r">
          <div class="rt" @click="friends">
            <p>邀请好友</p>
          </div>
          <div class="rb" @click="calculator">
            <p>计算器</p>
          </div>
        </div>
      </div>
      <div class="list">
        <div
          class="cell"
          v-for="(item, index) in data.items"
          :key="index"
          @click="detail(item.id)"
        >
          <div class="cell_l">
            <img :src="item.thumb" />
          </div>
          <div class="cell_r">
            <p class="title">{{ item.name }}</p>
            <p class="center">
              {{ item.item_desc }}
              <span>{{ item.money }}元</span>
            </p>
            <div class="jindu">
              <div class="progressbox">
                <div
                  class="progress"
                  :style="{ width: item.schedule.slice(0, 5) + '%' }"
                ></div>
              </div>
              <span>已售{{ item.schedule.slice(0, 5) }}%</span>
            </div>
            <div class="tagbox">
              <span>{{ item.min_money }}起投</span>
              <span>{{ item.days }}1天</span>
              <span>每日分红{{ item.apr_money }}元</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="appdown" v-show="down_show" v-if="data.app.is_disable === 'Y'">
      <div class="close_down">
        <a href="javascript:;" @click="appdown_close">
          <img src="@/assets/img/home/close.png" />
        </a>
      </div>
      <div class="logo">
        <img :src="data.app.image" width="100%" />
      </div>
      <div class="mark">
        <p>{{ data.app.text1 }}</p>
        <p>{{ data.app.text2 }}</p>
      </div>

      <div class="down">
        <a :href="data.app.app_link">下载</a>
      </div>
    </div>
    <div style="height: 50px"></div>
  </div>
</template>
<script>
import { Toast } from "vant";
import Swiper from "swiper";
import Fetch from "../../utils/fetch";
import "swiper/dist/css/swiper.min.css";
export default {
  name: "home",
  components: {},
  computed: {},
  data() {
    return {
      images: [{}, {}],
      data: {
        app: {},
      },
      down_show: true,
      link_width: 0,
      banner: [],
      notice: "",
      links: [],
      ad: {},
      ad_show: false,
    };
  },

  mounted() {},
  created() {
    this.init();
  },
  methods: {
    init() {
      Fetch("/api/api/image", { type: "banner" }).then((res) => {
        console.log(res.data);
        this.images = res.data;
        this.$nextTick(() => {
          var swiper = new Swiper(".swiper-container", {
            effect: "coverflow",
            loop: true,
            grabCursor: true,
            centeredSlides: true,
            slidesPerView: "auto",
            autoplay: 3000,
            autoplayDisableOnInteraction: false,
            // 如果需要分页器
            pagination: ".swiper-pagination",
            paginationClickable: true,
            coverflow: {
              rotate: 10,
              stretch: 0,
              depth: 100,
              modifier: 1,
              slideShadows: false,
            },
            spaceBetween: 30,
          });
        });
      });
      Fetch("/api/api/index").then((res) => {
        this.data = res.data;
      });
    },
    detail(id) {
      this.$router.push({
        //核心语句
        path: "/Investmentdetails", //跳转的路径
        query: {
          //路由传参时push和query搭配使用 ，作用时传递参数
          id: id,
        },
      });
    },
    appdown_close() {
      this.data.app.is_disable = "N";
    },
    capitaldetails() {
      this.$router.push({
        path: "/charge",
        query: {},
      });
    },
    qiandao() {
      this.$router.push({
        path: "/sign",
        query: {},
      });
    },
    friends() {
      this.$router.push({
        path: "/invited",
        query: {},
      });
    },
    onClickLeft() {
      Toast("返回");
    },
    onClickRight() {
      Toast("按钮");
    },
    orderlist() {
      this.$router.push({
        path: "/orderlist",
        // query: {
        // },
      });
    },
    calculator() {
      this.$router.push({
        path: "/calculator",
        // query: {
        // },
      });
    },
  },
};
</script>

<style scoped lang="less">
.home {
  width: 100%;
  height: 100%;
  background: #ffffff;
  .header {
    background: url("../../assets/img/home/header_bg.png") no-repeat;
    background-size: 100% 100%;
    width: 100%;
    height: 203px;
    .header_nav {
      padding: 15px;
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
    }
    .nav_l {
      text-align: left;
      h3 {
        font-size: 16px;
        font-family: PingFangSC, PingFangSC-Semibold;
        font-weight: 600;

        color: #ffffff;
      }
      p {
        opacity: 0.61;
        font-size: 9px;
        font-family: Helvetica;
        color: #ffffff;
      }
    }
    .nav_r {
      img {
        width: 28px;
        height: 28px;
      }
    }
  }
  .banner {
    margin-top: -150px;
  }
  .content {
    background: #fdfdfd;
    margin-top: 15px;
    .tip {
      margin: 0 18px;
      background: #f7f7f9;
      border-radius: 4px;
      box-shadow: 0px 2px 12px 2px rgba(0, 0, 0, 0.06);
      overflow: hidden;
      margin-top: 10px;
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      padding: 0 8px;
      margin-top: 25px;
      img {
        width: 22px;
        height: 22px;
      }
      /deep/.van-notice-bar {
        width: calc(100% - 40px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 15px;
        font-family: PingFangSC, PingFangSC-Regular;
        font-weight: 400;
        text-align: left;
        color: #404040;
      }
    }
    .model {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      padding: 15px;
      .model_l {
        width: 37%;
        height: 130px;
        background: url("../../assets/img/home/woyaochongzhi.png") no-repeat;
        background-size: 100% 100%;
        p {
          font-size: 16px;
          font-family: PingFangSC, PingFangSC-Regular;
          font-weight: 400;
          text-align: left;
          color: #503b1c;
          letter-spacing: -1px;
          margin: 15px;
        }
      }
      .model_r {
        width: 60%;
        height: 130px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        .rt {
          width: 100%;
          height: 61px;
          background: url("../../assets/img/home/yaoqinghaoyou.png") no-repeat;
          background-size: 100% 100%;

          p {
            font-size: 16px;
            font-family: PingFangSC, PingFangSC-Regular;
            font-weight: 400;
            text-align: left;
            color: #1e4339;
            letter-spacing: -1px;
            margin: 5px 18px;
          }
        }
        .rb {
          width: 100%;
          height: 61px;
          background: url("../../assets/img/home/jisuanqi.jpg") no-repeat;
          background-size: 100% 100%;
          p {
            font-size: 16px;
            font-family: PingFangSC, PingFangSC-Regular;
            font-weight: 400;
            text-align: left;
            color: #2d3d60;
            letter-spacing: -1px;
            margin: 5px 18px;
          }
        }
      }
    }
    .list {
      background: #f7f8f9;
      padding: 10px 15px;
    }
    .cell {
      background: #ffffff;
      border-radius: 5px;
      box-shadow: 0px 2px 12px 2px rgba(0, 0, 0, 0.06);
      overflow: hidden;
      margin-top: 10px;
      position: relative;
      .cell_l {
        width: 25%;
        height: 100%;
        float: left;
        position: absolute;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .cell_r {
        width: calc(75% - 28px);
        margin-left: 16px;
        float: right;
        padding: 6px 12px;
        .title {
          font-size: 15px;
          font-family: PingFangSC, PingFangSC-Medium;
          font-weight: 500;
          text-align: left;
          color: #2f2f2f;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          margin-bottom: 5px;
        }
        .center {
          font-size: 11px;
          font-family: PingFangSC, PingFangSC-Medium;
          font-weight: 500;
          text-align: left;
          color: #82818f;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          span {
            color: red;
          }
        }
        .jindu {
          display: flex;
          flex-direction: row;
          justify-content: flex-start;
          align-items: center;
          margin: 7px 0 15px 0;
          .progressbox {
            width: 65%;
            height: 5px;
            background: #fef2f2;
            border-radius: 3px;
            position: relative;
            text-align: center;
            overflow: hidden;
            .progress {
              width: 40%;
              position: absolute;
              left: 0;
              top: 0;
              height: 5px;
              background: #ff674c;
              border-radius: 3px;
            }
          }
          span {
            font-size: 10px;
            font-family: PingFangSC, PingFangSC-Medium;
            font-weight: 500;
            text-align: left;
            color: #999999;
            margin-left: 4px;
          }
        }
        .tagbox {
          span {
            display: inline-block;
            background: #fdece3;
            border-radius: 2px;
            overflow: hidden;
            padding: 5px;
            margin-right: 5px;
            font-size: 11px;
            font-family: PingFangSC, PingFangSC-Regular;
            font-weight: 400;
            text-align: left;
            color: #ff6f35;
          }
        }
      }
    }
  }
  .my-swipe .van-swipe-item {
    color: #fff;
    font-size: 20px;
    line-height: 150px;
    text-align: center;
    background-color: #39a9ed;
  }

  .swiper-container {
    z-index: 0;
    width: 100%;
    padding-top: 10px;

    .swiper-slide {
      background-position: center;
      background-size: cover;
      width: 80%;
      .swiper-img {
        border-radius: 10px;
        width: 100%;
        height: 160px;
      }
    }
  }
  .swiper-pagination {
    left: 50%;
    margin-left: -31px;
    /deep/.swiper-pagination-bullet {
      width: 16px;
      height: 2px;
      border-radius: inherit !important;
      background: #ff976a;
      margin-right: 5px;
    }
    /deep/.swiper-pagination-bullet-active {
      width: 16px;
      height: 2px;
      background: #ff5f46;
    }
  }
  .appdown {
    width: 100%;
    max-width: 750px;
    height: 56px;
    background-color: rgba(0, 0, 0, 0.5);
    position: fixed;
    font-size: 12px;
    bottom: 50px;

    .down {
      width: 65px;
      height: 100%;
      float: right;
      margin-right: 18px;
      display: flex;
      justify-content: center;
      align-items: center;

      a {
        border: 1px solid #ff3a50;
        border-radius: 6px;
        display: block;
        width: 100%;
        height: 26px;
        line-height: 26px;
        text-align: center;
        border-radius: 3px;
        font-size: 14px;
        font-family: PingFangSC, PingFangSC-Medium;
        font-weight: 500;
        color: #ff3a50;
      }
    }

    .close_down {
      width: 15px;
      float: right;
      height: 100%;
      font-size: 0.6rem;

      a {
        display: block;
        width: 15px;
        font-size: 14px;
        cursor: pointer;
        color: #fe8000;
        line-height: 25px;
        text-align: center;
      }
      img {
        width: 10px;
        height: 10px;
        margin: 0px 15px 0 0;
      }
    }

    .mark {
      float: left;
      height: 100%;
      color: #fff;
      line-height: 0.5rem;
      margin-left: 9px;
      display: flex;
      flex-wrap: wrap;
      flex-direction: column;
      justify-content: center;
      align-items: flex-start;
    }
    .mark p:nth-of-type(1) {
      line-height: 17px;
      font-size: 14px;
      font-family: PingFangSC, PingFangSC-Semibold;
      font-weight: 600;
      color: #ffffff;
    }
    .mark p:nth-of-type(2) {
      line-height: 14px;
      opacity: 0.8;
      font-size: 12px;
      font-family: PingFangSC, PingFangSC-Regular;
      font-weight: 400;
      color: #ffffff;
      margin-top: 2px;
    }
    .logo {
      width: 32px;
      height: 32px;
      float: left;
      margin-left: 8px;
      margin-top: 12px;
      img {
        max-height: 100%;
        border-radius: 6px;
      }
    }
  }
}
</style>